



package com.crm.manager.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.crm.manager.domain.Activity;
import com.crm.manager.domain.dto.ActivityDto;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 活动Mapper接口
 *
 * @author ruoyi
 * @date 2025-03-01
 */
@Mapper
public interface ActivityMapper extends BaseMapper<Activity>
{
    @Insert("INSERT INTO activity (begin_time, end_time, channel, code, discount, info, name, status, type, create_by, create_time, update_by, update_time,vouchers) " +
            "VALUES (#{beginTime}, #{endTime}, #{channel}, #{code}, #{discount}, #{info}, #{name}, #{status}, #{type}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime},#{vouchers})")
    void add(Activity activity);

    @Select("SELECT COUNT(*) FROM activity WHERE code = #{code}")
    int countByCode(String code);

    Page<Activity> page(ActivityDto dto);
    @Select("SELECT * FROM activity WHERE id = #{id}")
    Activity getById(Integer id);

    void delete(LambdaQueryWrapper<Activity> in);

    int delete(Integer[] ids);

    List<Activity> listselect(String channel);


    void update(Activity activity);

    @Select("SELECT type FROM activity WHERE id = #{activityId}")
    String getDiscountTypeById(@Param("activityId") Integer activityId);
}
